home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / GAS211S2.ZIP / src / gas-211 / include / dis-asm.h < prev    next >
C/C++ Source or Header  |  1993-05-30  |  4KB  |  105 lines

  1. #include <stdio.h>
  2. #include "ansidecl.h"
  3. #include "bfd.h"
  4.  
  5. typedef int (*fprintf_ftype) PARAMS((FILE*, const char*, ...));
  6.  
  7. typedef struct disassemble_info {
  8.   fprintf_ftype fprintf_func;
  9.   FILE *stream;
  10.  
  11.   /* For use by the disassembler.  */
  12.   int flags;
  13.   PTR private_data;
  14.  
  15.   /* Function used to get bytes to disassemble.  MEMADDR is the
  16.      address of the stuff to be disassembled, MYADDR is the address to
  17.      put the bytes in, and LENGTH is the number of bytes to read.
  18.      INFO is a pointer to this struct.
  19.      Returns an errno value or 0 for success.  */
  20.   int (*read_memory_func)
  21.     PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length,
  22.          struct disassemble_info *info));
  23.  
  24.   /* Function which should be called if we get an error that we can't
  25.      recover from.  STATUS is the errno value from read_memory_func and
  26.      MEMADDR is the address that we were trying to read.  INFO is a
  27.      pointer to this struct.  */
  28.   void (*memory_error_func)
  29.     PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info));
  30.  
  31.   /* Function called to print ADDR.  */
  32.   void (*print_address_func)
  33.     PARAMS ((bfd_vma addr, struct disassemble_info *info));
  34.  
  35.   /* These are for buffer_read_memory.  */
  36.   bfd_byte *buffer;
  37.   bfd_vma buffer_vma;
  38.   int buffer_length;
  39. } disassemble_info;
  40.  
  41. /* Here is a function which callers may wish to use for read_memory_func.
  42.    It gets bytes from a buffer.  */
  43. extern int buffer_read_memory
  44.   PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *));
  45.  
  46. /* This function goes with buffer_read_memory.
  47.    It prints a message using info->fprintf_func and info->stream.  */
  48. extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *));
  49.  
  50. /* Just print the address is hex.  This is included for completeness even
  51.    though both GDB and objdump provide their own (to print symbolic
  52.    addresses).  */
  53. extern void generic_print_address
  54.   PARAMS ((bfd_vma, struct disassemble_info *));
  55.  
  56. #define INIT_DISASSEMBLE_INFO(INFO, STREAM) \
  57.   (INFO).fprintf_func = (fprintf_ftype)fprintf, \
  58.   (INFO).stream = (STREAM), \
  59.   (INFO).buffer = NULL, \
  60.   (INFO).buffer_vma = 0, \
  61.   (INFO).buffer_length = 0, \
  62.   (INFO).read_memory_func = buffer_read_memory, \
  63.   (INFO).memory_error_func = perror_memory, \
  64.   (INFO).print_address_func = generic_print_address
  65.  
  66. /* GDB--Like target_read_memory, but slightly different parameters.  */
  67. extern int
  68. dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int len,
  69.                  disassemble_info *info));
  70.  
  71. /* GDB--Like memory_error with slightly different parameters.  */
  72. extern void
  73. dis_asm_memory_error
  74.   PARAMS ((int status, bfd_vma memaddr, disassemble_info *info));
  75.  
  76. /* GDB--Like print_address with slightly different parameters.  */
  77. extern void
  78. dis_asm_print_address PARAMS ((bfd_vma addr, disassemble_info *info));
  79.  
  80. #define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \
  81.   (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \
  82.   (INFO).stream = (STREAM), \
  83.   (INFO).read_memory_func = dis_asm_read_memory, \
  84.   (INFO).memory_error_func = dis_asm_memory_error, \
  85.   (INFO).print_address_func = dis_asm_print_address
  86.  
  87. /* Standard disassemblers.  Disassemble one instruction at the given
  88.    target address.  Return number of bytes processed.  */
  89. typedef int (*disassembler_ftype)
  90.      PARAMS((bfd_vma, disassemble_info *));
  91.  
  92. extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*));
  93. extern int print_insn_little_mips PARAMS ((bfd_vma,disassemble_info*));
  94. extern int print_insn_i386 PARAMS ((bfd_vma,disassemble_info*));
  95. extern int print_insn_m68k PARAMS ((bfd_vma,disassemble_info*));
  96. extern int print_insn_z8001 PARAMS ((bfd_vma,disassemble_info*));
  97. extern int print_insn_z8002 PARAMS ((bfd_vma,disassemble_info*));
  98. extern int print_insn_h8500 PARAMS ((bfd_vma,disassemble_info*));
  99. extern int print_insn_alpha PARAMS ((bfd_vma,disassemble_info*));
  100. extern int print_insn_sparc PARAMS ((bfd_vma,disassemble_info*));
  101. extern int print_insn_big_a29k PARAMS ((bfd_vma, disassemble_info*));
  102. extern int print_insn_little_a29k PARAMS ((bfd_vma, disassemble_info*));
  103. extern int print_insn_i960 PARAMS ((bfd_vma, disassemble_info*));
  104. extern int print_insn_sh PARAMS ((bfd_vma,disassemble_info*));
  105.